package net.stogi.unicore.beyond.ui.client.taskeditor.editormenu;

import net.stogi.common.gwt.dispatch.client.core.ActionManager;
import net.stogi.common.gwt.frame.client.core.EventBus;
import net.stogi.common.gwt.frame.client.mvp.AbstractPresenter;
import net.stogi.common.mvp.core.behavior.Behavior;
import net.stogi.unicore.beyond.ui.client.taskeditor.taskpreview.OpenTaskPreviewEvent;

class EditorMenuPresenter extends AbstractPresenter {

	private EditorMenuView editorMenuView;

	public EditorMenuPresenter(EditorMenuView editorMenuView, ActionManager actionManager, EventBus eventBus) {
		super(actionManager, eventBus);
		this.editorMenuView = editorMenuView;
		initBehavior();
		initHandlers();
	}

	@Override
	protected void initBehavior() {
		editorMenuView.setNewTaskBehavior(new Behavior() {
			
			@Override
			public void behave() {
				eventBus.fireEvent(new OpenTaskPreviewEvent());
				editorMenuView.unblockSaveTask();
			}
		});
		editorMenuView.setOpenTaskBehavior(new Behavior() {
			
			@Override
			public void behave() {
				eventBus.fireEvent(new OpenTaskSelectorEvent());
			}
		});
	}

	@Override
	protected void initHandlers() {}
}
